package com.hnkywl.jip.service;

import com.hnkywl.jip.dao.CompanyDao;
import com.hnkywl.jip.utils.CompanyData;
import net.ruixin.orm.hibernate.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jerry
 * Date: 13-3-1
 * Time: 上午10:07
 * To change this template use File | Settings | File Templates.
 */
@Service
public class CompanyService {
    private CompanyDao companyDao;

    @Transactional
    public List<Object[]> searchAllCompany(){
       return this.companyDao.searchAllCompany();
    }

    @Transactional
    public Page<Object[]> searchCompanyMapping(Integer companyId,Integer start,Integer limit){
        return this.companyDao.searchCompanyMapping(companyId,start,limit);
    }

    @Transactional
    public void saveCompanyMapping(List<CompanyData> companyDataList){
        for(CompanyData companyData:companyDataList)
             this.companyDao.saveCompanyMapping(companyData);
    }

    @Autowired
    public void setCompanyDao(CompanyDao companyDao) {
        this.companyDao = companyDao;
    }
}
